#-*- coding:utf-8 -*-

import pygame
import math
from pygame.locals import *

WINC = 'Winc'

class planet:
    def __init__(self, img, dx, roll, log, hide):
        self.pos_x = self.pos_y = 0
        self.log = log
        self.d = int(dx)
        self.dx = int(dx)
        self.hd = hide
        self.roll = roll
        self.roll_t = 0
        self.planet_img = pygame.image.load(img)
    
    def img(self):
        img = pygame.transform.scale(self.planet_img, (int(self.d), int(self.d)))
        return img
    
    def up(self, up=1.1):self.d *= up
    
    def low(self, low=0.9):self.d *= low

    def center(self):
        return -self.pos_x, -self.pos_y

    def update(self, screen, size, win, o=WINC):
        self.roll_t += self.roll
        if o == 'Winc':
            ox = size[0]//2
            oy = size[1]//2
        else:
            ox = o.pos_x
            oy = o.pos_y
        self.pos_x = int(ox + size[1]//self.log*math.sin(self.roll_t)*self.d/self.dx)
        self.pos_y = int(oy + size[1]//self.log*math.cos(self.roll_t)*self.d/self.dx)
        screen.blit(self.img(),[self.pos_x-self.d/2+win[0], self.pos_y-self.d/2+win[1]])